package codetop.microsoft.T36;

/**
 * @Author: 18362
 * @Create: 2022-09-11 21:14:25 星期日
 */
class Solution {
    public boolean isValidSudoku(char[][] board) {
        boolean[][] row = new boolean[9][9], col = new boolean[9][9], blk = new boolean[9][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (board[i][j] == '.')
                    continue;
                int num = board[i][j] - '0' - 1;
                int blkId = (i/3)*3 + (j/3);
                if (row[i][num] || col[j][num] || blk[blkId][num])
                    return false;
                row[i][num] = col[j][num] = blk[blkId][num] = true;
            }
        }
        return true;
    }
}
